'use strict'
import tape from 'tape'
import * as util from '../src/util'
import { ERC721 } from './data/ERC721'
import { sampleERC721 } from './data/sampleERC721'

tape('Util', function (t) {
  t.test('lowerbound', function (st) {
    st.plan(7)
    let array = [2, 5, 8, 9, 45, 56, 78]
    let lowerBound = util.findLowerBound(10, array)
    st.equal(lowerBound, 3)

    lowerBound = util.findLowerBound(3, array)
    st.equal(lowerBound, 0)

    lowerBound = util.findLowerBound(100, array)
    st.equal(lowerBound, 6)

    lowerBound = util.findLowerBound(1, array)
    st.equal(lowerBound, -1)

    lowerBound = util.findLowerBound(45, array)
    st.equal(lowerBound, 4)

    array = [2, 5, 8, 9, 9, 45, 56, 78]
    lowerBound = util.findLowerBound(9, array)
    st.equal(lowerBound, 4)

    lowerBound = util.findLowerBound(9, [])
    st.equal(lowerBound, -1)
  })
})

tape('util.groupBy on valid input', function (t) {
  t.plan(1)

  const result = util.groupBy([
    {category: 'GAS', name: 'a'},
    {category: 'SEC', name: 'b'},
    {category: 'GAS', name: 'c'}

  ], 'category')

  const expectedResult = {
    'GAS': [
      {category: 'GAS', name: 'a'},
      {category: 'GAS', name: 'c'}
    ],
    'SEC': [
      {category: 'SEC', name: 'b'}
    ]
  }

  t.deepEqual(result, expectedResult)
})

tape('util.concatWithSeperator valid output', function (t) {
  t.plan(4)
  t.notEqual(util.concatWithSeperator(['a', 'b', 'c'], ','), 'a, b, c', 'Concat with comma should not produce spaces')
  t.equal(util.concatWithSeperator(['a', 'b', 'c'], ','), 'a,b,c', 'Concat with comma should not produce spaces')
  t.equal(util.concatWithSeperator(['a', 'b', 'c'], ', '), 'a, b, c', 'Concat with comma space should not produce trailing comma')
  t.equal(util.concatWithSeperator(['a', 'b', 'c'], '+'), 'a+b+c', 'Concat with plus')
})

tape('util.escapeRegExp', function (t) {
  t.plan(3)
  const original = 'function (uint256) returns (bool)'
  t.equal(util.escapeRegExp('abcd'), 'abcd', 'String with no regex')
  t.equal(util.escapeRegExp(original), 'function \\(uint256\\) returns \\(bool\\)', 'function string with regex')
  t.ok(new RegExp(util.escapeRegExp(original)).test(original), 'should still test for original string')
})

tape('util.compareByteCode', function (t) {
  t.plan(5)

  const address = 'c2a9cef5420203c2672f0e4325cca774893cca98'
  const nullAddress = '0000000000000000000000000000000000000000'
  const deployedLibraryByteCode = '0x73c2a9cef5420203c2672f0e4325cca774893cca983014608060405260043610610058576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063f26ea02c1461005d575b600080fd5b81801561006957600080fd5b506100886004803603810190808035906020019092919050505061008a565b005b600081600101600060648110151561009e57fe5b600502016002018190555060008160010160006064811015156100bd57fe5b600502016004018190555060008160010160006064811015156100dc57fe5b6005020160030181905550600081600001819055506001816101f501819055816101f601819055506064816101f70181905550505600a165627a7a723058203a6f106db7413fd9cad962bc12ba2327799d6b1334335f7bb854eab04200b3bf0029'
  t.ok(util.compareByteCode(deployedLibraryByteCode, deployedLibraryByteCode.replace(address, nullAddress)), 'library bytecode should be the same')

  // ballot on ropsten - 0x96d87AB604AEC7FB26C2E046CA5e6eBBB9D8b74D
  const code1 = '0x608060405234801561001057600080fd5b50600436106100885760003560e01c8063609ff1bd1161005b578063609ff1bd146101925780639e7b8d61146101b0578063a3ec138d146101f4578063e2ba53f01461029157610088565b80630121b93f1461008d578063013cf08b146100bb5780632e4176cf146101045780635c19a95c1461014e575b600080fd5b6100b9600480360360208110156100a357600080fd5b81019080803590602001909291905050506102af565b005b6100e7600480360360208110156100d157600080fd5b810190808035906020019092919050505061044c565b604051808381526020018281526020019250505060405180910390f35b61010c61047d565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6101906004803603602081101561016457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506104a2565b005b61019a6108be565b6040518082815260200191505060405180910390f35b6101f2600480360360208110156101c657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610935565b005b6102366004803603602081101561020a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610b36565b60405180858152602001841515151581526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200194505050505060405180910390f35b610299610b93565b6040518082815260200191505060405180910390f35b6000600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020905060008160000154141561036d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260148152602001807f486173206e6f20726967687420746f20766f746500000000000000000000000081525060200191505060405180910390fd5b8060010160009054906101000a900460ff16156103f2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600e8152602001807f416c726561647920766f7465642e00000000000000000000000000000000000081525060200191505060405180910390fd5b60018160010160006101000a81548160ff02191690831515021790555081816002018190555080600001546002838154811061042a57fe5b9060005260206000209060020201600101600082825401925050819055505050565b6002818154811061045957fe5b90600052602060002090600202016000915090508060000154908060010154905082565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002090508060010160009054906101000a900460ff161561056a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260128152602001807f596f7520616c726561647920766f7465642e000000000000000000000000000081525060200191505060405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561060c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601e8152602001807f53656c662d64656c65676174696f6e20697320646973616c6c6f7765642e000081525060200191505060405180910390fd5b5b600073ffffffffffffffffffffffffffffffffffffffff16600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010160019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146107af57600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010160019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1691503373ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156107aa576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f466f756e64206c6f6f7020696e2064656c65676174696f6e2e0000000000000081525060200191505060405180910390fd5b61060d565b60018160010160006101000a81548160ff021916908315150217905550818160010160016101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002090508060010160009054906101000a900460ff16156108a2578160000154600282600201548154811061087f57fe5b9060005260206000209060020201600101600082825401925050819055506108b9565b816000015481600001600082825401925050819055505b505050565b6000806000905060008090505b6002805490508110156109305781600282815481106108e657fe5b9060005260206000209060020201600101541115610923576002818154811061090b57fe5b90600052602060002090600202016001015491508092505b80806001019150506108cb565b505090565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146109da576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526028815260200180610bc16028913960400191505060405180910390fd5b600160008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010160009054906101000a900460ff1615610a9d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260188152602001807f54686520766f74657220616c726561647920766f7465642e000000000000000081525060200191505060405180910390fd5b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000015414610aec57600080fd5b60018060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000018190555050565b60016020528060005260406000206000915090508060000154908060010160009054906101000a900460ff16908060010160019054906101000a900473ffffffffffffffffffffffffffffffffffffffff16908060020154905084565b60006002610b9f6108be565b81548110610ba957fe5b90600052602060002090600202016000015490509056fe4f6e6c79206368616972706572736f6e2063616e206769766520726967687420746f20766f74652ea26469706673582212205c306dddac7a80542891873341cf580f3b5920b0374bd5e32fe35fcabb116aaa64736f6c63430006010033'
  const code2 = '0x608060405234801561001057600080fd5b50600436106100885760003560e01c8063609ff1bd1161005b578063609ff1bd146101925780639e7b8d61146101b0578063a3ec138d146101f4578063e2ba53f01461029157610088565b80630121b93f1461008d578063013cf08b146100bb5780632e4176cf146101045780635c19a95c1461014e575b600080fd5b6100b9600480360360208110156100a357600080fd5b81019080803590602001909291905050506102af565b005b6100e7600480360360208110156100d157600080fd5b810190808035906020019092919050505061044c565b604051808381526020018281526020019250505060405180910390f35b61010c61047d565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6101906004803603602081101561016457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506104a2565b005b61019a6108be565b6040518082815260200191505060405180910390f35b6101f2600480360360208110156101c657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610935565b005b6102366004803603602081101561020a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610b36565b60405180858152602001841515151581526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200194505050505060405180910390f35b610299610b93565b6040518082815260200191505060405180910390f35b6000600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020905060008160000154141561036d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260148152602001807f486173206e6f20726967687420746f20766f746500000000000000000000000081525060200191505060405180910390fd5b8060010160009054906101000a900460ff16156103f2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600e8152602001807f416c726561647920766f7465642e00000000000000000000000000000000000081525060200191505060405180910390fd5b60018160010160006101000a81548160ff02191690831515021790555081816002018190555080600001546002838154811061042a57fe5b9060005260206000209060020201600101600082825401925050819055505050565b6002818154811061045957fe5b90600052602060002090600202016000915090508060000154908060010154905082565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002090508060010160009054906101000a900460ff161561056a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260128152602001807f596f7520616c726561647920766f7465642e000000000000000000000000000081525060200191505060405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561060c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601e8152602001807f53656c662d64656c65676174696f6e20697320646973616c6c6f7765642e000081525060200191505060405180910390fd5b5b600073ffffffffffffffffffffffffffffffffffffffff16600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010160019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146107af57600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010160019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1691503373ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156107aa576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f466f756e64206c6f6f7020696e2064656c65676174696f6e2e0000000000000081525060200191505060405180910390fd5b61060d565b60018160010160006101000a81548160ff021916908315150217905550818160010160016101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002090508060010160009054906101000a900460ff16156108a2578160000154600282600201548154811061087f57fe5b9060005260206000209060020201600101600082825401925050819055506108b9565b816000015481600001600082825401925050819055505b505050565b6000806000905060008090505b6002805490508110156109305781600282815481106108e657fe5b9060005260206000209060020201600101541115610923576002818154811061090b57fe5b90600052602060002090600202016001015491508092505b80806001019150506108cb565b505090565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146109da576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526028815260200180610bc16028913960400191505060405180910390fd5b600160008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060010160009054906101000a900460ff1615610a9d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260188152602001807f54686520766f74657220616c726561647920766f7465642e000000000000000081525060200191505060405180910390fd5b6000600160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000015414610aec57600080fd5b60018060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000018190555050565b60016020528060005260406000206000915090508060000154908060010160009054906101000a900460ff16908060010160019054906101000a900473ffffffffffffffffffffffffffffffffffffffff16908060020154905084565b60006002610b9f6108be565b81548110610ba957fe5b90600052602060002090600202016000015490509056fe4f6e6c79206368616972706572736f6e2063616e206769766520726967687420746f20766f74652ea26469706673582212207f175eb02901e2002e7a57d5736c3bea18bac88a3602e809c170e4a0da9dbf8d64736f6c63430006010033'
  t.ok(util.compareByteCode(code1, code2), 'should match even though cbor encoded metadatas are different')
  
  const storageCode1 = '0x608060405234801561001057600080fd5b50610150806100206000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c80632e64cec11461003b5780636057361d14610059575b600080fd5b610043610075565b60405161005091906100d9565b60405180910390f35b610073600480360381019061006e919061009d565b61007e565b005b60008054905090565b8060008190555050565b60008135905061009781610103565b92915050565b6000602082840312156100b3576100b26100fe565b5b60006100c184828501610088565b91505092915050565b6100d3816100f4565b82525050565b60006020820190506100ee60008301846100ca565b92915050565b6000819050919050565b600080fd5b61010c816100f4565b811461011757600080fd5b5056fea2646970667358221220c29dfcfdfd91e29bbf21ece97752e17fd3a0c07db30320f5b60b087866d2b7b164736f6c63430008070033'
  const storageCode2 = '0x608060405234801561001057600080fd5b506101e8806100206000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c80632e64cec11461003b5780636057361d14610059575b600080fd5b610043610075565b60405161005091906100ec565b60405180910390f35b610073600480360381019061006e91906100b0565b61007e565b005b60008054905090565b6000602a90506001826100919190610107565b6000819055505050565b6000813590506100aa8161019b565b92915050565b6000602082840312156100c6576100c5610196565b5b60006100d48482850161009b565b91505092915050565b6100e68161015d565b82525050565b600060208201905061010160008301846100dd565b92915050565b60006101128261015d565b915061011d8361015d565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0382111561015257610151610167565b5b828201905092915050565b6000819050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600080fd5b6101a48161015d565b81146101af57600080fd5b5056fea264697066735822122096fdfc54e6f9b12cf7a0e5d49289e40f3e9ed7554a1e5485cff008aebc78f27264736f6c63430008070033'
  t.ok(!util.compareByteCode(storageCode1, storageCode2), 'should not match')


  t.ok(!util.compareByteCode(sampleERC721, ERC721), 'should not match')

  const immutableRef1 = '0x6080604052600436106101145760003560e01c806352d1902d116100a057806395d89b411161006457806395d89b4114610380578063a457c2d7146103ab578063a9059cbb146103e8578063dd62ed3e14610425578063f2fde38b1461046257610114565b806352d1902d146102bf57806370a08231146102ea578063715018a6146103275780638129fc1c1461033e5780638da5cb5b1461035557610114565b8063313ce567116100e7578063313ce567146101e95780633659cfe614610214578063395093511461023d57806340c10f191461027a5780634f1ef286146102a357610114565b806306fdde0314610119578063095ea7b31461014457806318160ddd1461018157806323b872dd146101ac575b600080fd5b34801561012557600080fd5b5061012e61048b565b60405161013b919061228a565b60405180910390f35b34801561015057600080fd5b5061016b60048036038101906101669190611e3d565b61051d565b6040516101789190612239565b60405180910390f35b34801561018d57600080fd5b50610196610540565b6040516101a3919061250c565b60405180910390f35b3480156101b857600080fd5b506101d360048036038101906101ce9190611d8e565b61054a565b6040516101e09190612239565b60405180910390f35b3480156101f557600080fd5b506101fe610579565b60405161020b9190612527565b60405180910390f35b34801561022057600080fd5b5061023b60048036038101906102369190611d21565b610582565b005b34801561024957600080fd5b50610264600480360381019061025f9190611e3d565b61070b565b6040516102719190612239565b60405180910390f35b34801561028657600080fd5b506102a1600480360381019061029c9190611e3d565b610742565b005b6102bd60048036038101906102b89190611de1565b610758565b005b3480156102cb57600080fd5b506102d4610895565b6040516102e19190612254565b60405180910390f35b3480156102f657600080fd5b50610311600480360381019061030c9190611d21565b61094e565b60405161031e919061250c565b60405180910390f35b34801561033357600080fd5b5061033c610997565b005b34801561034a57600080fd5b506103536109ab565b005b34801561036157600080fd5b5061036a610b65565b604051610377919061221e565b60405180910390f35b34801561038c57600080fd5b50610395610b8f565b6040516103a2919061228a565b60405180910390f35b3480156103b757600080fd5b506103d260048036038101906103cd9190611e3d565b610c21565b6040516103df9190612239565b60405180910390f35b3480156103f457600080fd5b5061040f600480360381019061040a9190611e3d565b610c98565b60405161041c9190612239565b60405180910390f35b34801561043157600080fd5b5061044c60048036038101906104479190611d4e565b610cbb565b604051610459919061250c565b60405180910390f35b34801561046e57600080fd5b5061048960048036038101906104849190611d21565b610d42565b005b60606036805461049a906126d3565b80601f01602080910402602001604051908101604052809291908181526020018280546104c6906126d3565b80156105135780601f106104e857610100808354040283529160200191610513565b820191906000526020600020905b8154815290600101906020018083116104f657829003601f168201915b5050505050905090565b600080610528610dc6565b9050610535818585610dce565b600191505092915050565b6000603554905090565b600080610555610dc6565b9050610562858285610f99565b61056d858585611025565b60019150509392505050565b60006012905090565b7f000000000000000000000000d9145cce52d386f254917e481eb44e9943f3913873ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff161415610611576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106089061230c565b60405180910390fd5b7f000000000000000000000000d9145cce52d386f254917e481eb44e9943f3913873ffffffffffffffffffffffffffffffffffffffff166106506112a0565b73ffffffffffffffffffffffffffffffffffffffff16146106a6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161069d9061236c565b60405180910390fd5b6106af816112f7565b61070881600067ffffffffffffffff8111156106ce576106cd612794565b5b6040519080825280601f01601f1916602001820160405280156107005781602001600182028036833780820191505090505b506000611302565b50565b600080610716610dc6565b90506107378185856107288589610cbb565b61073291906125ca565b610dce565b600191505092915050565b61074a61147f565b61075482826114fd565b5050565b7f000000000000000000000000d9145cce52d386f254917e481eb44e9943f3913873ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff1614156107e7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107de9061230c565b60405180910390fd5b7f000000000000000000000000d9145cce52d386f254917e481eb44e9943f3913873ffffffffffffffffffffffffffffffffffffffff166108266112a0565b73ffffffffffffffffffffffffffffffffffffffff161461087c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108739061236c565b60405180910390fd5b610885826112f7565b61089182826001611302565b5050565b60007f000000000000000000000000d9145cce52d386f254917e481eb44e9943f3913873ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff1614610925576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161091c9061238c565b60405180910390fd5b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc60001b905090565b6000603360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b61099f61147f565b6109a96000611655565b565b60008060019054906101000a900460ff161590508080156109dc5750600160008054906101000a900460ff1660ff16105b80610a0957506109eb3061171b565b158015610a085750600160008054906101000a900460ff1660ff16145b5b610a48576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a3f906123cc565b60405180910390fd5b60016000806101000a81548160ff021916908360ff1602179055508015610a85576001600060016101000a81548160ff0219169083151502179055505b610af96040518060400160405280600781526020017f4d79546f6b656e000000000000000000000000000000000000000000000000008152506040518060400160405280600381526020017f4d544b000000000000000000000000000000000000000000000000000000000081525061173e565b610b0161179b565b610b096117f4565b8015610b625760008060016101000a81548160ff0219169083151502179055507f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024986001604051610b59919061226f565b60405180910390a15b50565b6000606560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060378054610b9e906126d3565b80601f0160208091040260200160405190810160405280929190818152602001828054610bca906126d3565b8015610c175780601f10610bec57610100808354040283529160200191610c17565b820191906000526020600020905b815481529060010190602001808311610bfa57829003601f168201915b5050505050905090565b600080610c2c610dc6565b90506000610c3a8286610cbb565b905083811015610c7f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c76906124cc565b60405180910390fd5b610c8c8286868403610dce565b60019250505092915050565b600080610ca3610dc6565b9050610cb0818585611025565b600191505092915050565b6000603460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b610d4a61147f565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610dba576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610db1906122cc565b60405180910390fd5b610dc381611655565b50565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610e3e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e359061248c565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610eae576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ea5906122ec565b60405180910390fd5b80603460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92583604051610f8c919061250c565b60405180910390a3505050565b6000610fa58484610cbb565b90507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff811461101f5781811015611011576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110089061232c565b60405180910390fd5b61101e8484848403610dce565b5b50505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611095576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161108c9061246c565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611105576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110fc906122ac565b60405180910390fd5b611110838383611845565b6000603360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905081811015611197576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161118e9061234c565b60405180910390fd5b818103603360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555081603360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051611287919061250c565b60405180910390a361129a84848461184a565b50505050565b60006112ce7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc60001b61184f565b60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6112ff61147f565b50565b61132e7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd914360001b611859565b60000160009054906101000a900460ff16156113525761134d83611863565b61147a565b8273ffffffffffffffffffffffffffffffffffffffff166352d1902d6040518163ffffffff1660e01b815260040160206040518083038186803b15801561139857600080fd5b505afa9250505080156113c957506040513d601f19601f820116820180604052508101906113c69190611e7d565b60015b611408576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113ff906123ec565b60405180910390fd5b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc60001b811461146d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611464906123ac565b60405180910390fd5b5061147983838361191c565b5b505050565b611487610dc6565b73ffffffffffffffffffffffffffffffffffffffff166114a5610b65565b73ffffffffffffffffffffffffffffffffffffffff16146114fb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114f29061242c565b60405180910390fd5b565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561156d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611564906124ec565b60405180910390fd5b61157960008383611845565b806035600082825461158b91906125ca565b9250508190555080603360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8360405161163d919061250c565b60405180910390a36116516000838361184a565b5050565b6000606560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081606560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b6000808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b600060019054906101000a900460ff1661178d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611784906124ac565b60405180910390fd5b6117978282611948565b5050565b600060019054906101000a900460ff166117ea576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117e1906124ac565b60405180910390fd5b6117f26119c9565b565b600060019054906101000a900460ff16611843576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161183a906124ac565b60405180910390fd5b565b505050565b505050565b6000819050919050565b6000819050919050565b61186c8161171b565b6118ab576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118a29061240c565b60405180910390fd5b806118d87f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc60001b61184f565b60000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b61192583611a2a565b6000825111806119325750805b15611943576119418383611a79565b505b505050565b600060019054906101000a900460ff16611997576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161198e906124ac565b60405180910390fd5b81603690805190602001906119ad929190611bcf565b5080603790805190602001906119c4929190611bcf565b505050565b600060019054906101000a900460ff16611a18576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a0f906124ac565b60405180910390fd5b611a28611a23610dc6565b611655565b565b611a3381611863565b8073ffffffffffffffffffffffffffffffffffffffff167fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b60405160405180910390a250565b6060611a848361171b565b611ac3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611aba9061244c565b60405180910390fd5b6000808473ffffffffffffffffffffffffffffffffffffffff1684604051611aeb9190612207565b600060405180830381855af49150503d8060008114611b26576040519150601f19603f3d011682016040523d82523d6000602084013e611b2b565b606091505b5091509150611b538282604051806060016040528060278152602001612d9960279139611b5d565b9250505092915050565b60608315611b6d57829050611b78565b611b778383611b7f565b5b9392505050565b600082511115611b925781518083602001fd5b806040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611bc6919061228a565b60405180910390fd5b828054611bdb906126d3565b90600052602060002090601f016020900481019282611bfd5760008555611c44565b82601f10611c1657805160ff1916838001178555611c44565b82800160010185558215611c44579182015b82811115611c43578251825591602001919060010190611c28565b5b509050611c519190611c55565b5090565b5b80821115611c6e576000816000905550600101611c56565b5090565b6000611c85611c8084612567565b612542565b905082815260208101848484011115611ca157611ca06127c8565b5b611cac848285612691565b509392505050565b600081359050611cc381612d53565b92915050565b600081519050611cd881612d6a565b92915050565b600082601f830112611cf357611cf26127c3565b5b8135611d03848260208601611c72565b91505092915050565b600081359050611d1b81612d81565b92915050565b600060208284031215611d3757611d366127d2565b5b6000611d4584828501611cb4565b91505092915050565b60008060408385031215611d6557611d646127d2565b5b6000611d7385828601611cb4565b9250506020611d8485828601611cb4565b9150509250929050565b600080600060608486031215611da757611da66127d2565b5b6000611db586828701611cb4565b9350506020611dc686828701611cb4565b9250506040611dd786828701611d0c565b9150509250925092565b60008060408385031215611df857611df76127d2565b5b6000611e0685828601611cb4565b925050602083013567ffffffffffffffff811115611e2757611e266127cd565b5b611e3385828601611cde565b9150509250929050565b60008060408385031215611e5457611e536127d2565b5b6000611e6285828601611cb4565b9250506020611e7385828601611d0c565b9150509250929050565b600060208284031215611e9357611e926127d2565b5b6000611ea184828501611cc9565b91505092915050565b611eb381612620565b82525050565b611ec281612632565b82525050565b611ed18161263e565b82525050565b6000611ee282612598565b611eec81856125ae565b9350611efc8185602086016126a0565b80840191505092915050565b611f118161267f565b82525050565b6000611f22826125a3565b611f2c81856125b9565b9350611f3c8185602086016126a0565b611f45816127d7565b840191505092915050565b6000611f5d6023836125b9565b9150611f68826127e8565b604082019050919050565b6000611f806026836125b9565b9150611f8b82612837565b604082019050919050565b6000611fa36022836125b9565b9150611fae82612886565b604082019050919050565b6000611fc6602c836125b9565b9150611fd1826128d5565b604082019050919050565b6000611fe9601d836125b9565b9150611ff482612924565b602082019050919050565b600061200c6026836125b9565b91506120178261294d565b604082019050919050565b600061202f602c836125b9565b915061203a8261299c565b604082019050919050565b60006120526038836125b9565b915061205d826129eb565b604082019050919050565b60006120756029836125b9565b915061208082612a3a565b604082019050919050565b6000612098602e836125b9565b91506120a382612a89565b604082019050919050565b60006120bb602e836125b9565b91506120c682612ad8565b604082019050919050565b60006120de602d836125b9565b91506120e982612b27565b604082019050919050565b60006121016020836125b9565b915061210c82612b76565b602082019050919050565b60006121246026836125b9565b915061212f82612b9f565b604082019050919050565b60006121476025836125b9565b915061215282612bee565b604082019050919050565b600061216a6024836125b9565b915061217582612c3d565b604082019050919050565b600061218d602b836125b9565b915061219882612c8c565b604082019050919050565b60006121b06025836125b9565b91506121bb82612cdb565b604082019050919050565b60006121d3601f836125b9565b91506121de82612d2a565b602082019050919050565b6121f281612668565b82525050565b61220181612672565b82525050565b60006122138284611ed7565b915081905092915050565b60006020820190506122336000830184611eaa565b92915050565b600060208201905061224e6000830184611eb9565b92915050565b60006020820190506122696000830184611ec8565b92915050565b60006020820190506122846000830184611f08565b92915050565b600060208201905081810360008301526122a48184611f17565b905092915050565b600060208201905081810360008301526122c581611f50565b9050919050565b600060208201905081810360008301526122e581611f73565b9050919050565b6000602082019050818103600083015261230581611f96565b9050919050565b6000602082019050818103600083015261232581611fb9565b9050919050565b6000602082019050818103600083015261234581611fdc565b9050919050565b6000602082019050818103600083015261236581611fff565b9050919050565b6000602082019050818103600083015261238581612022565b9050919050565b600060208201905081810360008301526123a581612045565b9050919050565b600060208201905081810360008301526123c581612068565b9050919050565b600060208201905081810360008301526123e58161208b565b9050919050565b60006020820190508181036000830152612405816120ae565b9050919050565b60006020820190508181036000830152612425816120d1565b9050919050565b60006020820190508181036000830152612445816120f4565b9050919050565b6000602082019050818103600083015261246581612117565b9050919050565b600060208201905081810360008301526124858161213a565b9050919050565b600060208201905081810360008301526124a58161215d565b9050919050565b600060208201905081810360008301526124c581612180565b9050919050565b600060208201905081810360008301526124e5816121a3565b9050919050565b60006020820190508181036000830152612505816121c6565b9050919050565b600060208201905061252160008301846121e9565b92915050565b600060208201905061253c60008301846121f8565b92915050565b600061254c61255d565b90506125588282612705565b919050565b6000604051905090565b600067ffffffffffffffff82111561258257612581612794565b5b61258b826127d7565b9050602081019050919050565b600081519050919050565b600081519050919050565b600081905092915050565b600082825260208201905092915050565b60006125d582612668565b91506125e083612668565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0382111561261557612614612736565b5b828201905092915050565b600061262b82612648565b9050919050565b60008115159050919050565b6000819050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b600061268a82612672565b9050919050565b82818337600083830152505050565b60005b838110156126be5780820151818401526020810190506126a3565b838111156126cd576000848401525b50505050565b600060028204905060018216806126eb57607f821691505b602082108114156126ff576126fe612765565b5b50919050565b61270e826127d7565b810181811067ffffffffffffffff8211171561272d5761272c612794565b5b80604052505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060008201527f64656c656761746563616c6c0000000000000000000000000000000000000000602082015250565b7f45524332303a20696e73756666696369656e7420616c6c6f77616e6365000000600082015250565b7f45524332303a207472616e7366657220616d6f756e742065786365656473206260008201527f616c616e63650000000000000000000000000000000000000000000000000000602082015250565b7f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060008201527f6163746976652070726f78790000000000000000000000000000000000000000602082015250565b7f555550535570677261646561626c653a206d757374206e6f742062652063616c60008201527f6c6564207468726f7567682064656c656761746563616c6c0000000000000000602082015250565b7f45524331393637557067726164653a20756e737570706f727465642070726f7860008201527f6961626c65555549440000000000000000000000000000000000000000000000602082015250565b7f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160008201527f647920696e697469616c697a6564000000000000000000000000000000000000602082015250565b7f45524331393637557067726164653a206e657720696d706c656d656e7461746960008201527f6f6e206973206e6f742055555053000000000000000000000000000000000000602082015250565b7f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60008201527f6f74206120636f6e747261637400000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60008201527f6e74726163740000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960008201527f6e697469616c697a696e67000000000000000000000000000000000000000000602082015250565b7f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760008201527f207a65726f000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a206d696e7420746f20746865207a65726f206164647265737300600082015250565b612d5c81612620565b8114612d6757600080fd5b50565b612d738161263e565b8114612d7e57600080fd5b50565b612d8a81612668565b8114612d9557600080fd5b5056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a264697066735822122066b4ca7b81ce7dbc6af77b0a062c617f3c53c6ec81d80662160ff3cdcd358a8064736f6c63430008070033'
  const immutableRef2 = '0x6080604052600436106101145760003560e01c806352d1902d116100a057806395d89b411161006457806395d89b4114610380578063a457c2d7146103ab578063a9059cbb146103e8578063dd62ed3e14610425578063f2fde38b1461046257610114565b806352d1902d146102bf57806370a08231146102ea578063715018a6146103275780638129fc1c1461033e5780638da5cb5b1461035557610114565b8063313ce567116100e7578063313ce567146101e95780633659cfe614610214578063395093511461023d57806340c10f191461027a5780634f1ef286146102a357610114565b806306fdde0314610119578063095ea7b31461014457806318160ddd1461018157806323b872dd146101ac575b600080fd5b34801561012557600080fd5b5061012e61048b565b60405161013b919061228a565b60405180910390f35b34801561015057600080fd5b5061016b60048036038101906101669190611e3d565b61051d565b6040516101789190612239565b60405180910390f35b34801561018d57600080fd5b50610196610540565b6040516101a3919061250c565b60405180910390f35b3480156101b857600080fd5b506101d360048036038101906101ce9190611d8e565b61054a565b6040516101e09190612239565b60405180910390f35b3480156101f557600080fd5b506101fe610579565b60405161020b9190612527565b60405180910390f35b34801561022057600080fd5b5061023b60048036038101906102369190611d21565b610582565b005b34801561024957600080fd5b50610264600480360381019061025f9190611e3d565b61070b565b6040516102719190612239565b60405180910390f35b34801561028657600080fd5b506102a1600480360381019061029c9190611e3d565b610742565b005b6102bd60048036038101906102b89190611de1565b610758565b005b3480156102cb57600080fd5b506102d4610895565b6040516102e19190612254565b60405180910390f35b3480156102f657600080fd5b50610311600480360381019061030c9190611d21565b61094e565b60405161031e919061250c565b60405180910390f35b34801561033357600080fd5b5061033c610997565b005b34801561034a57600080fd5b506103536109ab565b005b34801561036157600080fd5b5061036a610b65565b604051610377919061221e565b60405180910390f35b34801561038c57600080fd5b50610395610b8f565b6040516103a2919061228a565b60405180910390f35b3480156103b757600080fd5b506103d260048036038101906103cd9190611e3d565b610c21565b6040516103df9190612239565b60405180910390f35b3480156103f457600080fd5b5061040f600480360381019061040a9190611e3d565b610c98565b60405161041c9190612239565b60405180910390f35b34801561043157600080fd5b5061044c60048036038101906104479190611d4e565b610cbb565b604051610459919061250c565b60405180910390f35b34801561046e57600080fd5b5061048960048036038101906104849190611d21565b610d42565b005b60606036805461049a906126d3565b80601f01602080910402602001604051908101604052809291908181526020018280546104c6906126d3565b80156105135780601f106104e857610100808354040283529160200191610513565b820191906000526020600020905b8154815290600101906020018083116104f657829003601f168201915b5050505050905090565b600080610528610dc6565b9050610535818585610dce565b600191505092915050565b6000603554905090565b600080610555610dc6565b9050610562858285610f99565b61056d858585611025565b60019150509392505050565b60006012905090565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff161415610611576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106089061230c565b60405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166106506112a0565b73ffffffffffffffffffffffffffffffffffffffff16146106a6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161069d9061236c565b60405180910390fd5b6106af816112f7565b61070881600067ffffffffffffffff8111156106ce576106cd612794565b5b6040519080825280601f01601f1916602001820160405280156107005781602001600182028036833780820191505090505b506000611302565b50565b600080610716610dc6565b90506107378185856107288589610cbb565b61073291906125ca565b610dce565b600191505092915050565b61074a61147f565b61075482826114fd565b5050565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff1614156107e7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107de9061230c565b60405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166108266112a0565b73ffffffffffffffffffffffffffffffffffffffff161461087c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108739061236c565b60405180910390fd5b610885826112f7565b61089182826001611302565b5050565b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff1614610925576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161091c9061238c565b60405180910390fd5b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc60001b905090565b6000603360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b61099f61147f565b6109a96000611655565b565b60008060019054906101000a900460ff161590508080156109dc5750600160008054906101000a900460ff1660ff16105b80610a0957506109eb3061171b565b158015610a085750600160008054906101000a900460ff1660ff16145b5b610a48576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a3f906123cc565b60405180910390fd5b60016000806101000a81548160ff021916908360ff1602179055508015610a85576001600060016101000a81548160ff0219169083151502179055505b610af96040518060400160405280600781526020017f4d79546f6b656e000000000000000000000000000000000000000000000000008152506040518060400160405280600381526020017f4d544b000000000000000000000000000000000000000000000000000000000081525061173e565b610b0161179b565b610b096117f4565b8015610b625760008060016101000a81548160ff0219169083151502179055507f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024986001604051610b59919061226f565b60405180910390a15b50565b6000606560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060378054610b9e906126d3565b80601f0160208091040260200160405190810160405280929190818152602001828054610bca906126d3565b8015610c175780601f10610bec57610100808354040283529160200191610c17565b820191906000526020600020905b815481529060010190602001808311610bfa57829003601f168201915b5050505050905090565b600080610c2c610dc6565b90506000610c3a8286610cbb565b905083811015610c7f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c76906124cc565b60405180910390fd5b610c8c8286868403610dce565b60019250505092915050565b600080610ca3610dc6565b9050610cb0818585611025565b600191505092915050565b6000603460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b610d4a61147f565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610dba576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610db1906122cc565b60405180910390fd5b610dc381611655565b50565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610e3e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e359061248c565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610eae576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ea5906122ec565b60405180910390fd5b80603460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92583604051610f8c919061250c565b60405180910390a3505050565b6000610fa58484610cbb565b90507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff811461101f5781811015611011576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110089061232c565b60405180910390fd5b61101e8484848403610dce565b5b50505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611095576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161108c9061246c565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611105576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110fc906122ac565b60405180910390fd5b611110838383611845565b6000603360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905081811015611197576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161118e9061234c565b60405180910390fd5b818103603360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555081603360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051611287919061250c565b60405180910390a361129a84848461184a565b50505050565b60006112ce7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc60001b61184f565b60000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6112ff61147f565b50565b61132e7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd914360001b611859565b60000160009054906101000a900460ff16156113525761134d83611863565b61147a565b8273ffffffffffffffffffffffffffffffffffffffff166352d1902d6040518163ffffffff1660e01b815260040160206040518083038186803b15801561139857600080fd5b505afa9250505080156113c957506040513d601f19601f820116820180604052508101906113c69190611e7d565b60015b611408576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113ff906123ec565b60405180910390fd5b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc60001b811461146d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611464906123ac565b60405180910390fd5b5061147983838361191c565b5b505050565b611487610dc6565b73ffffffffffffffffffffffffffffffffffffffff166114a5610b65565b73ffffffffffffffffffffffffffffffffffffffff16146114fb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114f29061242c565b60405180910390fd5b565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561156d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611564906124ec565b60405180910390fd5b61157960008383611845565b806035600082825461158b91906125ca565b9250508190555080603360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8360405161163d919061250c565b60405180910390a36116516000838361184a565b5050565b6000606560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905081606560006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b6000808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b600060019054906101000a900460ff1661178d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611784906124ac565b60405180910390fd5b6117978282611948565b5050565b600060019054906101000a900460ff166117ea576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117e1906124ac565b60405180910390fd5b6117f26119c9565b565b600060019054906101000a900460ff16611843576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161183a906124ac565b60405180910390fd5b565b505050565b505050565b6000819050919050565b6000819050919050565b61186c8161171b565b6118ab576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118a29061240c565b60405180910390fd5b806118d87f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc60001b61184f565b60000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b61192583611a2a565b6000825111806119325750805b15611943576119418383611a79565b505b505050565b600060019054906101000a900460ff16611997576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161198e906124ac565b60405180910390fd5b81603690805190602001906119ad929190611bcf565b5080603790805190602001906119c4929190611bcf565b505050565b600060019054906101000a900460ff16611a18576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a0f906124ac565b60405180910390fd5b611a28611a23610dc6565b611655565b565b611a3381611863565b8073ffffffffffffffffffffffffffffffffffffffff167fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b60405160405180910390a250565b6060611a848361171b565b611ac3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611aba9061244c565b60405180910390fd5b6000808473ffffffffffffffffffffffffffffffffffffffff1684604051611aeb9190612207565b600060405180830381855af49150503d8060008114611b26576040519150601f19603f3d011682016040523d82523d6000602084013e611b2b565b606091505b5091509150611b538282604051806060016040528060278152602001612d9960279139611b5d565b9250505092915050565b60608315611b6d57829050611b78565b611b778383611b7f565b5b9392505050565b600082511115611b925781518083602001fd5b806040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611bc6919061228a565b60405180910390fd5b828054611bdb906126d3565b90600052602060002090601f016020900481019282611bfd5760008555611c44565b82601f10611c1657805160ff1916838001178555611c44565b82800160010185558215611c44579182015b82811115611c43578251825591602001919060010190611c28565b5b509050611c519190611c55565b5090565b5b80821115611c6e576000816000905550600101611c56565b5090565b6000611c85611c8084612567565b612542565b905082815260208101848484011115611ca157611ca06127c8565b5b611cac848285612691565b509392505050565b600081359050611cc381612d53565b92915050565b600081519050611cd881612d6a565b92915050565b600082601f830112611cf357611cf26127c3565b5b8135611d03848260208601611c72565b91505092915050565b600081359050611d1b81612d81565b92915050565b600060208284031215611d3757611d366127d2565b5b6000611d4584828501611cb4565b91505092915050565b60008060408385031215611d6557611d646127d2565b5b6000611d7385828601611cb4565b9250506020611d8485828601611cb4565b9150509250929050565b600080600060608486031215611da757611da66127d2565b5b6000611db586828701611cb4565b9350506020611dc686828701611cb4565b9250506040611dd786828701611d0c565b9150509250925092565b60008060408385031215611df857611df76127d2565b5b6000611e0685828601611cb4565b925050602083013567ffffffffffffffff811115611e2757611e266127cd565b5b611e3385828601611cde565b9150509250929050565b60008060408385031215611e5457611e536127d2565b5b6000611e6285828601611cb4565b9250506020611e7385828601611d0c565b9150509250929050565b600060208284031215611e9357611e926127d2565b5b6000611ea184828501611cc9565b91505092915050565b611eb381612620565b82525050565b611ec281612632565b82525050565b611ed18161263e565b82525050565b6000611ee282612598565b611eec81856125ae565b9350611efc8185602086016126a0565b80840191505092915050565b611f118161267f565b82525050565b6000611f22826125a3565b611f2c81856125b9565b9350611f3c8185602086016126a0565b611f45816127d7565b840191505092915050565b6000611f5d6023836125b9565b9150611f68826127e8565b604082019050919050565b6000611f806026836125b9565b9150611f8b82612837565b604082019050919050565b6000611fa36022836125b9565b9150611fae82612886565b604082019050919050565b6000611fc6602c836125b9565b9150611fd1826128d5565b604082019050919050565b6000611fe9601d836125b9565b9150611ff482612924565b602082019050919050565b600061200c6026836125b9565b91506120178261294d565b604082019050919050565b600061202f602c836125b9565b915061203a8261299c565b604082019050919050565b60006120526038836125b9565b915061205d826129eb565b604082019050919050565b60006120756029836125b9565b915061208082612a3a565b604082019050919050565b6000612098602e836125b9565b91506120a382612a89565b604082019050919050565b60006120bb602e836125b9565b91506120c682612ad8565b604082019050919050565b60006120de602d836125b9565b91506120e982612b27565b604082019050919050565b60006121016020836125b9565b915061210c82612b76565b602082019050919050565b60006121246026836125b9565b915061212f82612b9f565b604082019050919050565b60006121476025836125b9565b915061215282612bee565b604082019050919050565b600061216a6024836125b9565b915061217582612c3d565b604082019050919050565b600061218d602b836125b9565b915061219882612c8c565b604082019050919050565b60006121b06025836125b9565b91506121bb82612cdb565b604082019050919050565b60006121d3601f836125b9565b91506121de82612d2a565b602082019050919050565b6121f281612668565b82525050565b61220181612672565b82525050565b60006122138284611ed7565b915081905092915050565b60006020820190506122336000830184611eaa565b92915050565b600060208201905061224e6000830184611eb9565b92915050565b60006020820190506122696000830184611ec8565b92915050565b60006020820190506122846000830184611f08565b92915050565b600060208201905081810360008301526122a48184611f17565b905092915050565b600060208201905081810360008301526122c581611f50565b9050919050565b600060208201905081810360008301526122e581611f73565b9050919050565b6000602082019050818103600083015261230581611f96565b9050919050565b6000602082019050818103600083015261232581611fb9565b9050919050565b6000602082019050818103600083015261234581611fdc565b9050919050565b6000602082019050818103600083015261236581611fff565b9050919050565b6000602082019050818103600083015261238581612022565b9050919050565b600060208201905081810360008301526123a581612045565b9050919050565b600060208201905081810360008301526123c581612068565b9050919050565b600060208201905081810360008301526123e58161208b565b9050919050565b60006020820190508181036000830152612405816120ae565b9050919050565b60006020820190508181036000830152612425816120d1565b9050919050565b60006020820190508181036000830152612445816120f4565b9050919050565b6000602082019050818103600083015261246581612117565b9050919050565b600060208201905081810360008301526124858161213a565b9050919050565b600060208201905081810360008301526124a58161215d565b9050919050565b600060208201905081810360008301526124c581612180565b9050919050565b600060208201905081810360008301526124e5816121a3565b9050919050565b60006020820190508181036000830152612505816121c6565b9050919050565b600060208201905061252160008301846121e9565b92915050565b600060208201905061253c60008301846121f8565b92915050565b600061254c61255d565b90506125588282612705565b919050565b6000604051905090565b600067ffffffffffffffff82111561258257612581612794565b5b61258b826127d7565b9050602081019050919050565b600081519050919050565b600081519050919050565b600081905092915050565b600082825260208201905092915050565b60006125d582612668565b91506125e083612668565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0382111561261557612614612736565b5b828201905092915050565b600061262b82612648565b9050919050565b60008115159050919050565b6000819050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b600061268a82612672565b9050919050565b82818337600083830152505050565b60005b838110156126be5780820151818401526020810190506126a3565b838111156126cd576000848401525b50505050565b600060028204905060018216806126eb57607f821691505b602082108114156126ff576126fe612765565b5b50919050565b61270e826127d7565b810181811067ffffffffffffffff8211171561272d5761272c612794565b5b80604052505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b7f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060008201527f64656c656761746563616c6c0000000000000000000000000000000000000000602082015250565b7f45524332303a20696e73756666696369656e7420616c6c6f77616e6365000000600082015250565b7f45524332303a207472616e7366657220616d6f756e742065786365656473206260008201527f616c616e63650000000000000000000000000000000000000000000000000000602082015250565b7f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060008201527f6163746976652070726f78790000000000000000000000000000000000000000602082015250565b7f555550535570677261646561626c653a206d757374206e6f742062652063616c60008201527f6c6564207468726f7567682064656c656761746563616c6c0000000000000000602082015250565b7f45524331393637557067726164653a20756e737570706f727465642070726f7860008201527f6961626c65555549440000000000000000000000000000000000000000000000602082015250565b7f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160008201527f647920696e697469616c697a6564000000000000000000000000000000000000602082015250565b7f45524331393637557067726164653a206e657720696d706c656d656e7461746960008201527f6f6e206973206e6f742055555053000000000000000000000000000000000000602082015250565b7f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60008201527f6f74206120636f6e747261637400000000000000000000000000000000000000602082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60008201527f6e74726163740000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b7f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960008201527f6e697469616c697a696e67000000000000000000000000000000000000000000602082015250565b7f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760008201527f207a65726f000000000000000000000000000000000000000000000000000000602082015250565b7f45524332303a206d696e7420746f20746865207a65726f206164647265737300600082015250565b612d5c81612620565b8114612d6757600080fd5b50565b612d738161263e565b8114612d7e57600080fd5b50565b612d8a81612668565b8114612d9557600080fd5b5056fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a264697066735822122066b4ca7b81ce7dbc6af77b0a062c617f3c53c6ec81d80662160ff3cdcd358a8064736f6c63430008070033'
  t.ok(util.compareByteCode(immutableRef1, immutableRef2), 'code contains immutable refs and should match')

})

tape('util.getInputParameters', function (t) {
  t.plan(2)
  
  t.equal(util.getinputParameters(sampleERC721), '000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000001650000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000016500000000000000000000000000000000000000000000000000000000000000')
  t.equal(util.getinputParameters(ERC721), '')

})




